﻿using FastIOC;
using FastIOC.Builder;
using FastIOC.Proxy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Test.DBTest;
using Test.ServiceTest;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var container = new ContainerBuilder();
            container.RegisterType<Movie>().EnableInterfaceInterceptors().InterceptedBy<MoveIntercept>().UseAttributeIntercept();

            container.RegisterType<WebCatch>().As<ICatch>();
            container.RegisterType<DBCatch>().As<ICatch>();
            container.RegisterType<SQLServerCatch>().AsImplementedInterfaces();
            //container.RegisterType<MySQLCatch>().Named<ICatch>("MySQLCatch").EnableInterfaceInterceptors().InterceptedBy<DefaultIntercept>();
            container.RegisterType<MySQLCatch>().Named<ICatch>("MySQLCatch").EnableInterfaceInterceptors().InterceptedBy<DefaultIntercept>().UseAttributeIntercept();
            container.RegisterType<OracleCatch>().Named<ICatch>("OracleCatch");
            container.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies(),typeof(IBase)).AsImplementedInterfaces().EnableInterfaceInterceptors().InterceptedBy<DefaultIntercept>() ;

            //container.RegisterType<ModuleService>().AsImplementedInterfaces().EnableInterfaceInterceptors().InterceptedBy<DefaultIntercept>();

            container.Build();



            Movie movie = container.Resolve<Movie>();
            movie.MovieName = "1111";
            movie.Test();
            movie.Test1<MySQLCatch>().SaveCatch();



            ICatch catchtest = container.Resolve<ICatch>();
            catchtest.Catch("Catch111111");
            catchtest = container.ResolveNamed<ICatch>("MySQLCatch");
            catchtest.Catch("Catch222222");
            string result  = catchtest.SaveCatch();
            Console.WriteLine("saveresult:" + result);
            //IUser userservice = container.Resolve<IUser>();
            //userservice.Say();
            IModule module = container.Resolve<IModule>();
            ModuleArgs modulearg = new ModuleArgs();
            ModuleResult moduleresult = module.Add(modulearg);
            Console.WriteLine(moduleresult.AddDate);
            Console.ReadKey();
        }
    }
}
